using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class EmployeeStyleDAO
    {
        #region 4. Retrieving
        public static List<EmployeeStyleDTO> SelectEmployeeStyleAll()
        {
            List<EmployeeStyleDTO> list = new List<EmployeeStyleDTO>();
            try
            {
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("spSelectEmployeeStyleAll");
                foreach (DataRow dr in dt.Rows)
                {
                    EmployeeStyleDTO emp = new EmployeeStyleDTO();
                    emp.EmployeeStyleID = int.Parse(dr["EmployeeStyleID"].ToString());
                    emp.EmployeeStyleName = dr["EmployeeStyleName"].ToString();
                    list.Add(emp);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static EmployeeStyleDTO SelectEmployeeStyleByID(int employeeStyleID)
        {
            EmployeeStyleDTO emp = new EmployeeStyleDTO();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                sqlParams.Add(new SqlParameter("@EmployeeStyleID", employeeStyleID));
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("spSelectEmployeeStyleByID", sqlParams);
                DataRow dr = dt.Rows[0];
                emp.EmployeeStyleID = int.Parse (dr["EmployeeStyleID"].ToString());
                emp.EmployeeStyleName = dr["EmployeeStyleName"].ToString();                
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return emp;
        }

        public static bool CheckEmployeeStyleByID(int employeeStyleID)
        {
            bool result = false;
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                sqlParams.Add(new SqlParameter("@EmployeeStyleID", employeeStyleID));

                DataTable dt = SqlDataAccessHelper.ExecuteQuery("spSelectEmployeeStyleByID", sqlParams);
                if (dt.Rows.Count == 1)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }

        #endregion
    }
}
